package view.components;

import java.util.HashMap;

import javax.swing.JComboBox;
import javax.swing.JPanel;

import model.Constants;
import model.HostAddress;
import controller.Controller;

public class HostComboBox extends JPanel {
	private static final long serialVersionUID = 1L;

	private final JComboBox combo;
	private final HashMap<String, HostAddress> hostMap = new HashMap<String, HostAddress>();

	public HostComboBox() {

		combo = new JComboBox();
		combo.addItem(Constants.EMPTY);
		for (HostAddress element : Controller.getInstance().getHosts()) {
			combo.addItem(element.getHostAddress().getAddress());
			hostMap.put(element.getHostAddress().getAddress(), element);
		}

		this.add(combo);

	}

	public JComboBox getBox() {
		return combo;
	}

	public HashMap<String, HostAddress> getHostMap() {
		return hostMap;
	}
}
